package shareing

import "sync"

type Once[T any] struct {
	V   T
	New func() T

	one sync.Once
}

func (o *Once[T]) Do() T { o.one.Do(func() { o.V = o.New() }); return o.V }
